package com.medical.service.impl;

import com.medical.mapper.MessageCenterMapper;
import com.medical.pojo.MessageCenter;
import com.medical.service.MessageCenterService;
import com.medical.vo.Rmed;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MessageCenterServiceImpl implements MessageCenterService {

    @Autowired
    private MessageCenterMapper messageCenterMapper;

    @Override
    public List<MessageCenter> findAll(MessageCenter messageCenter) {
        return messageCenterMapper.findAll(messageCenter);
    }

    @Override
    public MessageCenter findById(Integer id) {
        return messageCenterMapper.findById(id);
    }

    @Override
    public Rmed addMessage(MessageCenter messageCenter) {
        Date date = new Date();
        messageCenter.setMessageLevel(messageCenter.getMessageLevel());
        messageCenter.setCreateTime(date);
        messageCenter.setMessageContent(messageCenter.getMessageContent());
        messageCenter.setMessageType(messageCenter.getMessageType());
        messageCenter.setTransferType(messageCenter.getTransferType());
        messageCenter.setMessageDetails(messageCenter.getMessageDetails());
        messageCenter.setMessagePeople(messageCenter.getMessagePeople());
        messageCenter.setMessagePhoto(messageCenter.getMessagePhoto());
        messageCenterMapper.addMessage(messageCenter);
        return Rmed.suceess();
    }

    @Override
    public void deleteOne(Integer id) {
        messageCenterMapper.deleteOne(id);
    }
}
